package com.ruoyi.hqfinance.service.impl;

import com.github.pagehelper.PageHelper;
import com.ruoyi.hqfinance.domain.HqPaiFeeThroughSheetByNet;
import com.ruoyi.hqfinance.domain.HqPaiFeeThroughSheetByNetAndArea;
import com.ruoyi.hqfinance.domain.HqPaiFeeThroughSheetByNetAndAreaAndSalesman;
import com.ruoyi.hqfinance.domain.vo.HqPaiFeeThroughSheetVo;
import com.ruoyi.hqfinance.mapper.HqPaiFeeThroughSheetByNetAndAreaAndSalesmanMapper;
import com.ruoyi.hqfinance.mapper.HqPaiFeeThroughSheetByNetAndAreaMapper;
import com.ruoyi.hqfinance.mapper.HqPaiFeeThroughSheetByNetMapper;
import com.ruoyi.hqfinance.service.HqPaiFeeThroughSheetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class HqPaiFeeThroughSheetServiceImpl implements HqPaiFeeThroughSheetService {
    @Autowired
    private HqPaiFeeThroughSheetByNetMapper hqPaiFeeThroughSheetByNetMapper;
    @Autowired
    private HqPaiFeeThroughSheetByNetAndAreaMapper hqPaiFeeThroughSheetByNetAndAreaMapper;
    @Autowired
    private HqPaiFeeThroughSheetByNetAndAreaAndSalesmanMapper hqPaiFeeThroughSheetByNetAndAreaAndSalesmanMapper;
    @Override
    public List<HqPaiFeeThroughSheetByNet> collectA(HqPaiFeeThroughSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqPaiFeeThroughSheetByNet> paiFeeThroughSheets =  hqPaiFeeThroughSheetByNetMapper.collect(vo);
        assert paiFeeThroughSheets != null;
        for (HqPaiFeeThroughSheetByNet hqPaiFeeThroughSheet : paiFeeThroughSheets){
            if (vo.getCollectType() == 2){
                hqPaiFeeThroughSheet.setDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return paiFeeThroughSheets;
    }

    @Override
    public List<HqPaiFeeThroughSheetByNetAndArea> collectB(HqPaiFeeThroughSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqPaiFeeThroughSheetByNetAndArea> paiFeeThroughSheets =  hqPaiFeeThroughSheetByNetAndAreaMapper.collect(vo);
        assert paiFeeThroughSheets != null;
        for (HqPaiFeeThroughSheetByNetAndArea hqPaiFeeThroughSheet : paiFeeThroughSheets){
            if (vo.getCollectType() == 2){
                hqPaiFeeThroughSheet.setDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return paiFeeThroughSheets;
    }

    @Override
    public List<HqPaiFeeThroughSheetByNetAndAreaAndSalesman> collectC(HqPaiFeeThroughSheetVo vo) {
        PageHelper.startPage(vo.getPageDate());
        List<HqPaiFeeThroughSheetByNetAndAreaAndSalesman> paiFeeThroughSheets =  hqPaiFeeThroughSheetByNetAndAreaAndSalesmanMapper.collect(vo);
        assert paiFeeThroughSheets != null;
        for (HqPaiFeeThroughSheetByNetAndAreaAndSalesman hqPaiFeeThroughSheet : paiFeeThroughSheets){
            if (vo.getCollectType() == 2){
                hqPaiFeeThroughSheet.setDate(vo.getStartTime() + "至" + vo.getEndTime());
            }
        }
        return paiFeeThroughSheets;
    }
}
